﻿
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class Thorn : MonoBehaviour
{
    public Action HitSomeMonsterEvent;
    [SerializeField]
    private SpriteRenderer m_spriteRenderer;
    [SerializeField]
    private BoxCollider m_collider;

    private void OnEnable()
    {
        m_collider.enabled = false;
        this.transform.localScale = Vector3.zero;
        this.transform.DOScale(Vector3.one, 1f).OnComplete(() =>
          {
              m_collider.enabled = true;
          });
    }
    public void SetColor(Color32 pColor)
    {
        m_spriteRenderer.color = pColor;
    }
    public void SetSprite(Sprite pSprite)
    {
        m_spriteRenderer.sprite = pSprite;
    }
    public void SetLocalPos(Vector3 pLocalPos)
    {
        this.transform.localPosition = pLocalPos;
    }
    public void SetLocalRotate(Quaternion pLocalRot)
    {
        this.transform.localRotation = pLocalRot;
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent<Monster>().curScale < 2f)
        {
            return;
        }
        Destroy(this.gameObject);
        if (HitSomeMonsterEvent != null) HitSomeMonsterEvent.Invoke();
    }
}
